# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time

from openerp import SUPERUSER_ID
from openerp.osv import fields, osv

class hr_overtime(osv.osv):
    
    _name = 'hr.overtime'
    _description = 'Overtime'
    
    _columns = {
        'name': fields.char('Description', size=64, required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
        'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Approval'), ('refuse', 'Refused'), ('validate1', 'Waiting Second Approval'), ('validate', 'Approved'), ('cancel', 'Cancelled')], 
                                  'Status', readonly=True, track_visibility='onchange', copy=False),
        'overtime_type_id': fields.many2one('hr.overtime.type', 'Overtime Type', required=True, readonly=True, states={'draft':[('readonly',False)]}),
        'employee_id': fields.many2one('hr.employee', 'Employee', required=True, readonly=True, states={'draft':[('readonly',False)]}), 
        'breaktime' : fields.float('Break Time', readonly=True, states={'draft':[('readonly',False)]}),
        'date_from': fields.date('Start Date', required=True, readonly=True, states={'draft':[('readonly',False)]}), 
        'date_to': fields.date('End Date', required=True, readonly=True, states={'draft':[('readonly',False)]}), 
        'number_of_hours_temp' : fields.float('OT Hours Estimation', readonly=True, states={'draft':[('readonly',False)]}),
        'total_ot_hours' : fields.float('Total OT Hours'),
        'manager_id1': fields.many2one('hr.employee', 'First Approval', required=True, readonly=True, states={'draft':[('readonly',False)]}), 
        'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, states={'draft':[('readonly',False)]}), 
        'overtime_type': fields.many2one('hr.overtime.hour', 'Overtime Category', required=True, readonly=True, states={'draft':[('readonly',False)]}),
        'dept_id': fields.many2one('hr.department', 'Department', readonly=True, states={'draft':[('readonly',False)]}),
        'actual_ot_hours' : fields.float('Actual OT Hours'),
        'user_id': fields.many2one('res.users', 'Creator', readonly=True), 
        'notes': fields.text('Notes'),       
        }
    
    _defaults = {
        'state' : 'draft',
        }
class hr_overtime_type(osv.osv):
    
    _name = 'hr.overtime.type'
    _description = 'Overtime Type'
     
    _columns = {
        'name': fields.char('Description', size=64, required=True),
        'active': fields.boolean('Active'),
        'double_validation': fields.boolean('Apply Double Validation'),    
    }

 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
